-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove label from dataview checkbox #67868
base: trunk
Are you sure you want to change the base?
Remove label from dataview checkbox #67868
Conversation
This reverts commit 63f81c1.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
I'd totally support not using dynamic labels. Labels determine the accessible name of a control, which should rarely change dynamically. For checkboxes, the checked state is implied and natively communicated to assistive technologies. |
A pre-existing issue is that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't aria-label={ selectionLabel }
be just the label
prop?
Replacing aria-label with the label prop results in the label being visually displayed next to the checkbox (which may not be desirable in this context)
You’re absolutely right, an unlabelled checkbox would be a critical accessibility issue. I will ensure that if the selectionLabel is not set or is empty, a fallback label such as "Select item" or the item's title is used as a default. |
packages/dataviews/src/components/dataviews-selection-checkbox/index.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes sense to me. Screen readers appear to work properly both with and without titles:
54d09f32641d1b647adf7d87639487f7.mp4
@afercia Any additional feedback would be appreciated.
@afercia - Please let us know if you have any additional comments, or else we can move forward. Thank you |
What?
Fixes #59178
This PR updates the labels associated with checkboxes in data views to remove the dynamically generated state values (Select item: and Deselect item:). The labels now display only the relevant item title, simplifying and improving accessibility.
Why?
The current implementation of checkbox labels includes dynamic state indicators (Select item: and Deselect item:) which
overcomplicate the labels and do not adhere to the semantic purpose of labels as descriptors of the control.
How?
Removed the dynamic prefixes (Select item: and Deselect item:) from the checkbox labels in the code. Updated the label to display only the item's title, derived from the provided titleField property.
Testing Instructions
Screenshots or screencast
REC-20241212152215.mp4